package cn.seecoder.courselearning.vo.post;

import cn.seecoder.courselearning.po.post.Post;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NonNull;

import java.util.Date;
import java.util.List;

@Data
public class PostVO {
    private Integer id;

    private String title;

    private String content;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    private Integer userId;

    private  String userName;

    private Integer courseId;

    private String courseName;



    private Date lastReplyTime;

//    // 标记当前用户（学生）是否已购买解锁
//    private boolean bought;
//
//    // 标记当前用户（老师）是否有权限管理课程
//    private boolean manageable;

    private List<Integer> allReplyId;

    public PostVO(){
//        bought = false;
//    manageable = false;
    }

    public PostVO(@NonNull Post post){
        id = post.getId();
        title = post.getTitle();
        content = post.getContent();
        createTime = post.getCreateTime();
        userId = post.getUserId();
        courseId = post.getCourseId();;
        lastReplyTime = post.getLastReplyTime();
        allReplyId = post.getAllReplyId();
//        bought = false;
//        manageable = false;
    }

    public PostVO(@NonNull Post post, String userName,String courseName){
        id = post.getId();
        title = post.getTitle();
        content = post.getContent();
        createTime = post.getCreateTime();
        userId = post.getUserId();
        courseId = post.getCourseId();;
        lastReplyTime = post.getLastReplyTime();
        allReplyId = post.getAllReplyId();
        this.userName = userName;
        this.courseName = courseName;
//        this.bought = bought;
//        this.manageable = manageable;
    }
}
